cmake_minimum_required(VERSION 3.20)

set(CMAKE_CXX_STANDARD 17)

#工程名
SET(PROJECT_NAME "demo_t2sdk")
project(${PROJECT_NAME})

macro(add_source name dir)
	include_directories(${dir})
	set(hfind ${ARGV1})
	string(APPEND hfind "/*.h")
	set(cppfind ${ARGV1})
	string(APPEND cppfind "/*.cpp")
	set(cfind ${ARGV1})
	string(APPEND cfind "/*.c")
	file(GLOB name_header ${hfind})
	file(GLOB name_cpp ${cppfind})
	file(GLOB name_c ${cfind})
	set(sourcfiles ${sourcfiles}  ${name_header} ${name_cpp} ${name_c})
	source_group(${ARGV0} FILES  ${name_header} ${name_cpp} ${name_c})
endmacro(add_source)

add_definitions("-DFMT_HEADER_ONLY")

# 设置输出路径
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output)
#SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/output)
#SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/output)

if(WIN32)
	add_definitions("-D_CRT_SECURE_NO_WARNINGS")
	add_definitions("-DWINDOWSCODE")
	#设置SAFESEH为NO
	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
	set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
endif()

add_source(src ./src)
add_source(t2sdk ./t2sdk)
add_source(json ../../source/jsoncpp)
add_source(Platform ../../source/Platform)

include_directories(../../../../..//spdlog)

link_directories(${PROJECT_SOURCE_DIR}/t2sdk/x64)

add_executable(${PROJECT_NAME} ${sourcfiles})

if(WIN32)
	target_link_libraries(${PROJECT_NAME} t2sdk.lib HsFutuSystemInfo.lib)
else()
	target_link_libraries(${PROJECT_NAME} libt2sdk.so libHsFutuSystemInfo.so)
endif()

